﻿using System;
using System.Runtime.Serialization;


namespace Communergy.Common
{
    [DataContract]
    public class EnergyInformation : EnergyData
    {
		#region Fields (5) 

        private int joules;
        private decimal kWh;

		#endregion Fields 

		#region Constructors (3) 

        public EnergyInformation(EnergyData energyData) : this(energyData.ReadingDateTime, energyData.Interval, energyData.AverageWatts) 
        {
            
        }
        public EnergyInformation(DateTime readingDateTime, TimeSpan interval, decimal averageWatts)
            : this(readingDateTime, interval)
        {
            AverageWatts = averageWatts;
            joules = averageWatts.WattsIntervalToJoules(interval);
            kWh = joules.JoulesToKWh();            
        }

       

        private EnergyInformation(DateTime readingDateTime, TimeSpan interval)
        {
            ReadingDateTime = readingDateTime;
            Interval = interval;
        }

		#endregion Constructors 

		#region Properties (6) 

               
        public int Joules
        {
            get
            {
                return joules;
            }          
        }

        public decimal KWh
        {
            get
            {
                return kWh;
            }
        }

        public DateTime PeriodEnd
        {
            get
            {
                return ReadingDateTime.Add(Interval);
            }
        }

		#endregion Properties 

	
    }
}
